// pages/immediately-order/immediately-order.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls:{
      img1:"../../images/banner.png",
      img2:"../../images/banner.png",
      img3:"../../images/banner.png"
    },
    top:"../../images/top.png",
    date:"选择预约时间",
    star:"选择天象",
    time:"",
    dateArry:[
      {name:'3月1日'},
      {name:'3月2日'},
      {name:'3月3日'},
      {name:'3月4日'},
      {name:'3月5日'},
      {name:'3月6日'}],
    selectDate:true,
    selectStar:true,
    selectArea:false,
    starArea:false,
    timeArray:[
      {name:'8:00-8:20',checked: false},
      {name:'9:00-9:20',checked: false},
      {name:'10:20-10:40',checked: false},
      {name:'13:30-13:50',checked: false},
      {name:'14:30-14:50',checked: false}],
    starArry:[
      {name:'金星'},
      {name:'水星'},
      {name:'火星'},
      {name:'木星'}],
    index: 0,
    index2: 0,
    hide:true,
    selectOption:'',
    showPop:true,
    indicatorDots: true,
    autoplay: false,
    interval: 5000,
    duration: 1000,
    indicatorColor:'#104166',
    indicatorActiveColor:'#4393d0',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  //选择日期
  clickDate:function(){
    var selectDate = this.data.selectDate;
    if(selectDate == true){
      this.setData({
        selectArea:true,
        selectDate:false,
      })
    }else{
      this.setData({
        selectArea:false,
        selectDate:true,
      })
    }
  } ,

  mySelect:function(e){
    this.setData({
      date:e.target.dataset.me,
      selectDate:true,
      selectArea:false,
    })
  },

  //选择天象
  clickStar:function(){
    var selectStar = this.data.selectStar;
    if(selectStar == true){
      this.setData({
        starArea:true,
        selectStar:false,
      })
    }else{
      this.setData({
        starArea:false,
        selectStar:true,
      })
    }
  } ,

  mySelectStar:function(e){
    this.setData({
      star:e.target.dataset.me,
      selectStar:true,
      starArea:false,
    })
  },


  //选择时间
  chooseTime:function(e){
    var that = this;
    var index = e.target.dataset.index;
    var timeArray = that.data.timeArray;
    if (timeArray[index]['checked'] == false) {
      for (var i = 0; i < timeArray.length; i++) {
        timeArray[i]['checked'] = false;
      };
      timeArray[index]['checked'] = true;
      that.setData({
        time:e.target.dataset.me
      })
    }else{
      for (var i = 0; i < timeArray.length; i++) {
        timeArray[i]['checked'] = false;
      };
      that.setData({
        time:""
      })
    }
    that.setData({
      timeArray:timeArray
    })
    console.log(that.data.time);
  },

  turnTo:function(){
    wx.navigateTo({
      url: '../../pages/order-guide/order-guide'
    })
  },

  showPop:function(){
    var that = this;
    that.setData({
      showPop:false
    })
  },

  clickTap:function(e){
    var type = e.detail.type;
    var that = this;
    console.log(type);
    if (type == '取消') {
      that.setData({
        showPop:true
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})